USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Configrations-Insert]    Script Date: [[20120914064948]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064948]]
-- Description:	Insert record into table [dbo].[Configrations]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Configrations-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Configrations-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Configrations-Insert]
	/*@Configuration_RowNumber int =Null OUTPUT , 
	@Configuration_ID uniqueidentifier =Null  , 
	@Configuration_Name varchar(300) =Null  , 
	@Configuration_Value varchar(300) =Null  , 
	@Configuration_Notes varchar(max) =Null  , 
	@Configuration_Search varchar(max) =Null  , 
	@Configration_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[Configrations](/*[Configuration_ID], [Configuration_Name], [Configuration_Value], [Configuration_Notes], [Configuration_Search]*/)
	VALUES     (/*@Configuration_ID, @Configuration_Name, @Configuration_Value, @Configuration_Notes, @Configuration_Search*/)

	/*SELECT @Configuration_RowNumber = [Configuration_RowNumber], @Configration_TimeStamp = [Configration_TimeStamp]
    FROM [dbo].[Configrations]
    WHERE  ( [Configuration_ID] =@Configuration_ID )
	AND  ( [Configuration_Name] =@Configuration_Name )
	AND  ( [Configuration_Value] =@Configuration_Value )
	AND  ( [Configuration_Notes] =@Configuration_Notes )
	AND  ( [Configuration_Search] =@Configuration_Search )*/
END
GO
-- =============================================
USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Configrations-update]    Script Date: [[20120914064948]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064948]]
-- Description:	Update record in table [dbo].[Configrations]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Configrations-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Configrations-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Configrations-update]
	/*@Configuration_RowNumber int =Null OUTPUT , 
	@Configuration_ID uniqueidentifier =Null  , 
	@Configuration_Name varchar(300) =Null  , 
	@Configuration_Value varchar(300) =Null  , 
	@Configuration_Notes varchar(max) =Null  , 
	@Configuration_Search varchar(max) =Null  , 
	@Configration_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [Configration_TimeStamp]
    FROM [dbo].[Configrations]
    	WHERE ([Configuration_ID] = @Configuration_ID)

    IF  @OldTimeStamp = @Configration_TimeStamp
    BEGIN*/
		Update [dbo].[Configrations] SET 
		/*[Configuration_ID] =@Configuration_ID, 
		[Configuration_Name] =@Configuration_Name, 
		[Configuration_Value] =@Configuration_Value, 
		[Configuration_Notes] =@Configuration_Notes, 
		[Configuration_Search] =@Configuration_Search*/
		/*WHERE ([Configuration_ID] = @Configuration_ID)*/
	/*END*/

	/*SELECT @Configuration_RowNumber = [Configuration_RowNumber], @Configration_TimeStamp = [Configration_TimeStamp]
    FROM [dbo].[Configrations]
	WHERE ([Configuration_ID] = @Configuration_ID)*/
END
GO
-- =============================================
USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Configrations-Insert-Update]    Script Date: [[20120914064948]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064948]]
-- Description:	Insert OR Update record into table [dbo].[Configrations]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Configrations-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Configrations-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Configrations-Insert-Update]
	/*@Configuration_RowNumber int =Null OUTPUT , 
	@Configuration_ID uniqueidentifier =Null  , 
	@Configuration_Name varchar(300) =Null  , 
	@Configuration_Value varchar(300) =Null  , 
	@Configuration_Notes varchar(max) =Null  , 
	@Configuration_Search varchar(max) =Null  , 
	@Configration_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[Configrations] 
					/*WHERE ([Configuration_ID] = @Configuration_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[Configrations](/*[Configuration_ID], [Configuration_Name], [Configuration_Value], [Configuration_Notes], [Configuration_Search]*/)
		VALUES     (/*@Configuration_ID, @Configuration_Name, @Configuration_Value, @Configuration_Notes, @Configuration_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [Configration_TimeStamp]
		FROM [dbo].[Configrations]
    	WHERE ([Configuration_ID] = @Configuration_ID)

		IF  @OldTimeStamp = @Configration_TimeStamp
		BEGIN*/
			Update [dbo].[Configrations] SET 
			/*[Configuration_ID] =@Configuration_ID, 
			[Configuration_Name] =@Configuration_Name, 
			[Configuration_Value] =@Configuration_Value, 
			[Configuration_Notes] =@Configuration_Notes, 
			[Configuration_Search] =@Configuration_Search*/
			/*WHERE ([Configuration_ID] = @Configuration_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @Configuration_RowNumber = [Configuration_RowNumber], @Configration_TimeStamp = [Configration_TimeStamp]
    FROM [dbo].[Configrations]
	WHERE ([Configuration_ID] = @Configuration_ID)*/
END
GO
-- =============================================
USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Configrations-Delete]    Script Date: [[20120914064948]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064948]]
-- Description:	delete records from table [dbo].[Configrations] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Configrations-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Configrations-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Configrations-Delete]
	/*@Configuration_RowNumber int =null  , 
	@Configuration_ID uniqueidentifier =null  , 
	@Configuration_Name varchar(300) =null  , 
	@Configuration_Value varchar(300) =null  , 
	@Configuration_Notes varchar(max) =null  , 
	@Configuration_Search varchar(max) =null  , 
	@Configration_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[Configrations]
	WHERE /*( [Configuration_RowNumber] = ISNULL(@Configuration_RowNumber, [Configuration_RowNumber]) )
	AND ( [Configuration_ID] = ISNULL(@Configuration_ID, [Configuration_ID]) )
	AND ( [Configuration_Name] like ISNULL(@Configuration_Name, [Configuration_Name]) )
	AND ( [Configuration_Value] like ISNULL(@Configuration_Value, [Configuration_Value]) )
	AND ( [Configuration_Notes] like ISNULL(@Configuration_Notes, [Configuration_Notes]) )
	AND ( [Configuration_Search] like ISNULL(@Configuration_Search, [Configuration_Search]) )
	AND ( [Configration_TimeStamp] = ISNULL(@Configration_TimeStamp, [Configration_TimeStamp]) )*/
END
GO
-- =============================================
USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Configrations-Select]    Script Date: [[20120914064948]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064948]]
-- Description:	select records from table [dbo].[Configrations] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Configrations-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Configrations-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Configrations-Select]
	/*@Configuration_RowNumber int =null  , 
	@Configuration_ID uniqueidentifier =null  , 
	@Configuration_Name varchar(300) =null  , 
	@Configuration_Value varchar(300) =null  , 
	@Configuration_Notes varchar(max) =null  , 
	@Configuration_Search varchar(max) =null  , 
	@Configration_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[Configrations]
	WHERE /*( [Configuration_RowNumber] = ISNULL(@Configuration_RowNumber, [Configuration_RowNumber]) )
	AND ( [Configuration_ID] = ISNULL(@Configuration_ID, [Configuration_ID]) )
	AND ( [Configuration_Name] like ISNULL(@Configuration_Name, [Configuration_Name]) )
	AND ( [Configuration_Value] like ISNULL(@Configuration_Value, [Configuration_Value]) )
	AND ( [Configuration_Notes] like ISNULL(@Configuration_Notes, [Configuration_Notes]) )
	AND ( [Configuration_Search] like ISNULL(@Configuration_Search, [Configuration_Search]) )
	AND ( [Configration_TimeStamp] = ISNULL(@Configration_TimeStamp, [Configration_TimeStamp]) )*/
END
GO
-- =============================================
